new Vue({
    el: "#main",
    data: {
        username: "",
        password: "",
    },
    methods: {
        login: function () {
            axios.post("http://localhost:8080/back-login", {
                username: this.username,
                password: this.password
            }).then(response => {
                if (response.data.code == 200) {
                    localStorage.setItem('adminId', response.data.data.adminId);
                    localStorage.setItem("nickName", response.data.data.username + response.data.data.role || "用户" + Math.random() * 10000000000000);
                    localStorage.setItem("role", response.data.data.role)
                    location.href = "back-index.html";
                }
            }).catch(error => { // 添加错误处理
                console.error("登录请求失败:", error);
            });
        }
    }
})